package org.xinjiang.tarim.travel.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.xinjiang.tarim.travel.model.RouteMdd;
import org.xinjiang.tarim.travel.service.RouteMddService;
import org.xinjiang.tarim.travel.utils.Constants;
import org.xinjiang.tarim.travel.utils.JsonResult;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/api/routeMdd")
public class RouteMddApi {
    @Autowired
    RouteMddService routeMddService;

    /**
     * 获取行程目的地
     * @param routeId
     * @return
     */
    @RequestMapping(value = "/getByRouteId")
    public JsonResult seletcByRouteId(Long routeId){
        JsonResult jsonResult;
        try {
            List routeMdds = routeMddService.seletcByRouteId(routeId);
            if(routeMdds.size() == 0){
                jsonResult = new JsonResult(Constants.STATUS_FAIL, "查询失败");
            }else {
                jsonResult = new JsonResult(Constants.STATUS_SUCCESS, "查询成功", routeMdds);
            }
        }catch (Exception e){
            jsonResult = new JsonResult(Constants.STATUS_ERROR, "查询异常");
        }
        return jsonResult;
    }
}
